unit sprite;

{$mode objfpc}{$H+}

interface

uses
  Classes,
  SysUtils,
  zgl_textures,
  zgl_render_target,
  zgl_textures_png,
  zgl_textures_jpg,
  zglSpriteEngine;

type

  { TSprite }

  TSprite = class(zglCSprite2D)
  private
    procedure OnInit( _Texture : zglPTexture; _Layer : Integer ); override;
    procedure OnDraw; override;
    procedure OnProc; override;
    procedure OnFree; override;
  public
    constructor Create( _Manager : zglCSEngine2D; _ID : Integer ); override;
    procedure LoadImage(filename: string);
    destructor Free;
  end;

implementation

{ TSprite }

procedure TSprite.LoadImage(filename: string);
begin
 WriteLn('Citam: '  + filename);
 if not FileExists(filename) then
   WriteLn('[Greska!] - Grafika ''' + filename + ''' ne postoji!')
 else
   Texture := tex_LoadFromFile(filename, $FF000000, TEX_DEFAULT_2D);
end;

procedure TSprite.OnInit(_Texture: zglPTexture; _Layer: Integer);
begin
  inherited OnInit(_Texture, _Layer);
end;

procedure TSprite.OnDraw;
begin
  inherited OnDraw;
end;

procedure TSprite.OnProc;
begin
  inherited OnProc;
end;

procedure TSprite.OnFree;
begin
  inherited OnFree;
end;

constructor TSprite.Create(_Manager: zglCSEngine2D; _ID: Integer);
begin
  inherited Create(_Manager, _ID);
  ID := _Manager.AddSprite();
  _Manager.List[ID] := Self;
end;

destructor TSprite.Free;
begin
  inherited Destroy;
end;

end.

